<template>
    <div class="view-main">
        <div class="view-header">
            <el-radio-group v-model="timeSelect" @change="queryTimeChanged">
                <el-radio-button label="全部"></el-radio-button>
                <el-radio-button label="今日"></el-radio-button>
                <el-radio-button label="本周"></el-radio-button>
                <el-radio-button label="本月"></el-radio-button>
                <el-radio-button label="自定义"></el-radio-button>
            </el-radio-group>
            <el-date-picker v-if="timeShow" v-model="timeRange" type="datetimerange" format="yyyy-MM-dd HH:mm:ss"
                            value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                            align="right" @change="handleTimeRangeChanged">
            </el-date-picker>
            <el-input placeholder="案卷名称" v-model="queryParam.name" style="width: 200px"></el-input>
            <el-input placeholder="案卷编号" v-model="queryParam.code" style="width: 200px" ></el-input>

            <span>
        <el-button type="primary" @click="getDataList()" icon="el-icon-search">查询</el-button>
        <el-button type="primary" @click="handleAdd()" icon="el-icon-search">入库</el-button>

      </span>
        </div>
        <div class="view-body">
            <div class="light-table">
                <el-table :data="tableData" height="300" highlight-current-row style="width: 100%">
                    <el-table-column property="name" label="卷宗名称" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column property="code" label="卷宗编号" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column property="jzType" label="卷宗类型" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column property="registDate" label="登记时间" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column property="registrant" label="登记人" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column property="status" label="卷宗状态" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column property="position" label="存储位置" align="center" show-overflow-tooltip></el-table-column>
                    <!--<el-table-column label="操作" align="center" width="350">-->
                    <el-table-column label="操作" align="center" width="330">
                        <template slot-scope="scope">
                            <!--v-if 控制每个状态后的按钮-->
                            <el-button type="text" size="mini" @click="handleTracks(scope.row)">轨迹</el-button>
                            <el-button v-if="scope.row.status == '已入库'" type="text" size="mini" @click="handleTempOut(scope.row)">临时出库</el-button>
                            <el-button v-if="scope.row.status == '临时出库'" type="text" size="mini" @click="handleTempBack(scope.row)">归还入库</el-button>
                            <el-button v-if="scope.row.status != '临时出库' && scope.row.status !='移交出库'"type="text" size="mini" @click="handleEverOut(scope.row)">移交出库</el-button>

                            <!--<el-button type="text" size="mini" @click="handleDetail(scope.row)">详情</el-button>-->
                            <!--<el-button type="text" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>-->
                            <!--<el-button type="text" class="danger-color" size="mini" @click="handleDelete(scope.row)">删除</el-button>-->


                                <el-popover
                                        style="margin-left: 10px"
                                        placement="top-start"
                                        title=""
                                        width="150"
                                        trigger="hover">

                                    <el-button type="text" size="mini" @click="handleDetail(scope.row)">详情</el-button>
                                    <el-button type="text" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
                                    <el-button type="text" class="danger-color" size="mini" @click="handleDelete(scope.row)">删除</el-button>

                                    <el-button slot="reference" icon="el-icon-more"></el-button>
                                </el-popover>


                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination background layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 20, 50, 100]"
                               :total="total" :current-page="pageNum" :page-size.sync="pageSize" :page-count="pages"
                               @current-change="handlePageChange" @size-change="handleSizeChange"></el-pagination>
            </div>
        </div>


        <!--入库,编辑-->
        <el-dialog class="no-bottom-padding user-dialog" :title="typeText" :visible.sync="dialogVisible" width="480px" :close-on-click-modal="false">
            <el-form :model="addForm" :rules="addRules" ref="addForm" label-width="100px" size="mini" style="padding-right: 20px" :disabled="type_dia === 2">
                <!--选择框-->
                <el-form-item label="案件名称" prop="name">
                    <el-select v-model="addForm.name" filterable placeholder="请选择" :change="visableOther(addForm.name)">
                        <el-option
                                v-for="item in ajList"
                                :key="item.name"
                                :label="item.name"
                                :value="item.name">
                        </el-option>
                    </el-select>
                </el-form-item>

                <!--案卷名称关联，不可改-->
                <el-form-item label="案卷编号" prop="code" >
                    <el-input v-model.number="addForm.code" clearable disabled></el-input>
                </el-form-item>

                <!--案卷名称关联，不可改-->
                <el-form-item label="案卷类型" prop="zjType">
                    <el-input v-model.number="addForm.ajType" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="卷宗类型" prop="jzType">
                    <el-select v-model="addForm.jzType" filterable placeholder="请选择" >
                        <el-option
                                v-for="item in jzList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="登记人" prop="registrant">
                    <el-select v-model="addForm.registrant" placeholder="请选择">
                        <el-option
                                v-for="item in registrants"
                                :key="item.realName"
                                :label="item.realName"
                                :value="item.realName">
                        </el-option>
                    </el-select>
                </el-form-item>

                <!--需要关联登记人,所以每个人注册时需要加入登记单位,或者学习财务系统,改为申请单位-->
                <el-form-item label="申请单位"  prop="applyUnit">
                    <el-input v-model.number="addForm.applyUnit" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="登记时间"  prop="registDate">
                    <el-date-picker type="date"  v-model="addForm.registDate" style="width: 100%;"
                                    value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                </el-form-item>

                <el-form-item label="存放位置"  prop="position">
                    <el-input v-model.number="addForm.position" clearable></el-input>
                </el-form-item>

                <el-form-item label="卷宗描述"  prop="description">
                    <el-input v-model.number="addForm.description" clearable></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" v-if="type_dia < 2">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="updateConfirm('addForm')">确 定</el-button>
            </div>
        </el-dialog>
        <!--临时出库-->
        <el-dialog class="no-bottom-padding user-dialog" :title="typeText" :visible.sync="outDialogVisible" width="480px" :close-on-click-modal="false">
            <el-form :model="tempOutForm" :rules="tempOutRules" ref="tempOutForm" label-width="100px" size="mini" style="padding-right: 20px">
                <!--选择框-->
                <el-form-item label="申请人" prop="tempApplyMan">
                    <el-select v-model="tempOutForm.tempApplyMan" placeholder="请选择">
                        <el-option
                                v-for="item in tempApplyMans"
                                :key="item.realName"
                                :label="item.realName"
                                :value="item.realName">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="申请单位" prop="tempApplyUnit" >
                    <el-input v-model.number="tempOutForm.tempApplyUnit" clearable></el-input>
                </el-form-item>

                <el-form-item label="接收人" prop="tempRecipient" >
                    <el-input v-model.number="tempOutForm.tempRecipient" clearable></el-input>
                </el-form-item>

                <el-form-item label="接收单位" prop="tempRecUnit" >
                    <el-input v-model.number="tempOutForm.tempRecUnit" clearable></el-input>
                </el-form-item>

                <el-form-item label="申请时间"  prop="tempApplyTime">
                    <el-date-picker type="date"  v-model="tempOutForm.tempApplyTime" style="width: 100%;"
                                    value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                </el-form-item>

                <el-form-item label="预计时间"  prop="tempPreBackTime">
                    <el-date-picker type="date"  v-model="tempOutForm.tempPreBackTime" style="width: 100%;"
                                    value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                </el-form-item>

                <el-form-item label="申请事由" prop="tempReason" >
                    <el-input v-model.number="tempOutForm.tempReason" clearable></el-input>
                </el-form-item>

                <!--展示-->
                <el-form-item label="案卷名称" prop="name" >
                    <el-input v-model.number="tempOutForm.name" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="案卷编号" prop="code" >
                    <el-input v-model.number="tempOutForm.code" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="案卷类型" prop="ajType" >
                    <el-input v-model.number="tempOutForm.ajType" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="卷宗类型" prop="jzType" >
                    <el-input v-model.number="tempOutForm.jzType" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="存放位置" prop="position" >
                    <el-input v-model.number="tempOutForm.position" clearable disabled></el-input>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="outDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="handleTempOutConfirm('tempOutForm')">确 定</el-button>
            </div>
        </el-dialog>
        <!--归还入库-->
        <el-dialog class="no-bottom-padding user-dialog" :title="typeText" :visible.sync="backDialogVisible" width="480px" :close-on-click-modal="false">
            <el-form :model="tempBackForm" :rules="tempBackRules" ref="tempBackForm" label-width="100px" size="mini" style="padding-right: 20px">
                <!--选择框-->
                <el-form-item label="申请人" prop="tempBackMan">
                    <el-select v-model="tempBackForm.tempBackMan" placeholder="请选择">
                        <el-option
                                v-for="item in tempBackMans"
                                :key="item.realName"
                                :label="item.realName"
                                :value="item.realName">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="归还时间" prop="tempBackTime" >
                    <el-date-picker type="date"  v-model="tempBackForm.tempBackTime" style="width: 100%;"
                                    value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                </el-form-item>


                <el-form-item label="存放位置" prop="position" >
                    <el-input v-model.number="tempBackForm.position" clearable></el-input>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="outDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="handleTempBackConfirm('tempBackForm')">确 定</el-button>
            </div>
        </el-dialog>
        <!--移交出库-->
        <el-dialog class="no-bottom-padding user-dialog" :title="typeText" :visible.sync="everOutDialogVisible" width="480px" :close-on-click-modal="false">
            <el-form :model="everOutForm" :rules="everOutFormRules" ref="everOutForm" label-width="100px" size="mini" style="padding-right: 20px">
                <!--选择框-->
                <el-form-item label="申请人" prop="everApplyMan">
                    <el-select v-model="everOutForm.everApplyMan" placeholder="请选择">
                        <el-option
                                v-for="item in everApplyMans"
                                :key="item.realName"
                                :label="item.realName"
                                :value="item.realName">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="申请单位" prop="everApplyUnit" >
                    <el-input v-model.number="everOutForm.everApplyUnit" clearable></el-input>
                </el-form-item>

                <el-form-item label="接收人" prop="everRecipient" >
                    <el-input v-model.number="everOutForm.everRecipient" clearable></el-input>
                </el-form-item>

                <el-form-item label="接收单位" prop="everRecUnit" >
                    <el-input v-model.number="everOutForm.everRecUnit" clearable></el-input>
                </el-form-item>

                <el-form-item label="申请时间"  prop="everApplyTime">
                    <el-date-picker type="date"  v-model="everOutForm.everApplyTime" style="width: 100%;"
                                    value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                </el-form-item>

                <el-form-item label="申请事由" prop="everReason" >
                    <el-input v-model.number="everOutForm.everReason" clearable></el-input>
                </el-form-item>

                <!--展示-->
                <el-form-item label="案卷名称" prop="name" >
                    <el-input v-model.number="everOutForm.name" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="案卷编号" prop="code" >
                    <el-input v-model.number="everOutForm.code" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="案卷类型" prop="ajType" >
                    <el-input v-model.number="everOutForm.ajType" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="卷宗类型" prop="jzType" >
                    <el-input v-model.number="everOutForm.jzType" clearable disabled></el-input>
                </el-form-item>

                <el-form-item label="存放位置" prop="position" >
                    <el-input v-model.number="everOutForm.position" clearable disabled></el-input>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="everOutDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="handleEverOutConfirm('everOutForm')">确 定</el-button>
            </div>
        </el-dialog>
        <!--轨迹-->
        <el-dialog class="no-bottom-padding user-dialog" :title="typeText" :visible.sync="tracksDialogVisible" width="480px" :close-on-click-modal="false">
            <div class="block">
                <el-timeline>
                    <el-timeline-item v-if="tracksForm.everApplyMan != null" :timestamp="tracksForm.everApplyTime" placement="top">
                        <el-card>
                            <p>{{tracksForm.everApplyMan}} 提交于 {{tracksForm.everApplyTime}}</p>
                            <h4>移交出库</h4>
                        </el-card>
                    </el-timeline-item>
                    <el-timeline-item v-if="tracksForm.tempBackMan != null" :timestamp="tracksForm.tempBackTime" placement="top">
                        <el-card>
                            <p>{{tracksForm.tempBackMan}} 提交于 {{tracksForm.tempBackTime}}</p>
                            <h4>归还入库</h4>
                        </el-card>
                    </el-timeline-item>
                    <el-timeline-item v-if="tracksForm.tempApplyMan != null" :timestamp="tracksForm.tempApplyTime" placement="top">
                        <el-card>
                            <p>{{tracksForm.tempApplyMan}} 提交于 {{tracksForm.tempApplyTime}}</p>
                            <h4>临时出库</h4>
                        </el-card>
                    </el-timeline-item>
                    <el-timeline-item v-if="tracksForm.registrant != null" :timestamp="tracksForm.registDate" placement="top">
                        <el-card>
                            <p>{{tracksForm.registrant}} 提交于 {{tracksForm.registDate}}</p>
                            <h4>初始入库</h4>
                        </el-card>
                    </el-timeline-item>
                </el-timeline>
            </div>
        </el-dialog>

    </div>
</template>

<script>
    import { isEmpty, formatDate, stringFormat,getStartTimeOfDate, getEndTimeOfDate, getStartTimeOfWeek, getEndTimeOfWeek, getStartTimeOfMonth, getEndTimeOfMonth } from '../../utils/util'
    // import { checkLoginName, checkPhone, checkEmail, checkObj, isEmpty, stringFormat } from '../../utils/util'

    import { getAction } from '@/utils/manage'

    export default {
        name: 'fileRecord',
        data() {
            return {
                visible: false,
                tracksDialogVisible:false,
                everOutDialogVisible:false,
                backDialogVisible:false,
                outDialogVisible:false,
                dialogVisible: false,
                type_dia: 0,
                timeSelect: '全部',
                queryParam: {
                    name: '',
                    code: '',
                    startLogTime:'',
                    endLogTime:'',
                },
                ajList:[],
                jzList: [
                    { value: "刑侦案卷", label: "刑侦案卷" },
                    { value: "治安案卷", label: "治安案卷" },
                    { value: "行政案卷", label: "行政案卷" },
                    { value: "工作卷", label: "工作卷" },
                    { value: "侦察卷", label: "侦察卷" }
                ],
                registrants: [ ],
                tempApplyMans: [ ],
                tempBackMans: [ ],
                everApplyMans: [ ],

                addForm: {
                    //
                    value:'',
                    name: '',
                    code: '',
                    ajType:'',
                    jzType:'',
                    registDate:'',
                    registrant:'',
                    status:'',
                    position:'',
                    applyUnit:'',
                    description:''
                },
                //临时出库
                tempOutForm:{
                    //临时出库申请人
                    tempApplyMan:'',
                    tempApplyUnit:'',
                    tempRecipient:'',
                    tempRecUnit:'',
                    tempApplyTime:'',
                    tempPreBackTime:'',
                    tempReason:'',
                    name: '',
                    ajType:'',
                    code: '',
                    jzType:'',
                    position:'',
                    status:''
                },
                //归还入库
                tempBackForm:{
                    tempBackMan:'',
                    tempBackTime:'',
                    position:'',
                    status:''
                },
                //移交出库
                everOutForm:{
                    everApplyMan:'',
                    everApplyUnit:'',
                    everRecipient:'',
                    everRecUnit:'',
                    everApplyTime:'',
                    everReason:'',
                    name: '',
                    ajType:'',
                    code: '',
                    jzType:'',
                    position:'',
                    status:''
                },
                //轨迹
                tracksForm:{
                    registDate:'',
                    tempapplytime:'',
                    tempbacktime:'',
                    everApplytime:'',
                },
                jzId: 0,
                //卷宗历史记录
                jzManageHistory:{
                    jzId: '',
                    action: ''
                },
                everOutFormRules:{
                    everApplyMan: [{ required: true, message: '请选择申请人', trigger: 'blur' }],
                    everApplyUnit: [{ required: true, message: '请选择申请单位', trigger: 'blur' }],
                    everRecipient: [{ required: true, message: '请输入接收人', trigger: 'blur' }],
                    everRecUnit: [{ required: true, message: '请选择接收单位', trigger: 'blur' }],
                    everApplyTime: [{ required: true, message: '请选择申请时间', trigger: 'blur' }],
                    everReason: [{ required: true, message: '请输入申请事由', trigger: 'blur' }],
                },
                tempOutRules:{
                    tempApplyMan: [{ required: true, message: '请选择申请人', trigger: 'blur' }],
                    tempApplyUnit: [{ required: true, message: '请选择申请单位', trigger: 'blur' }],
                    tempRecipient: [{ required: true, message: '请输入接收人', trigger: 'blur' }],
                    tempRecUnit: [{ required: true, message: '请选择接收单位', trigger: 'blur' }],
                    tempApplyTime: [{ required: true, message: '请选择申请时间', trigger: 'blur' }],
                    tempReason: [{ required: true, message: '请输入申请事由', trigger: 'blur' }],
                },
                tempBackRules:{
                    tempBackMan: [{ required: true, message: '请选择申请人', trigger: 'blur' }],
                    tempBackTime: [{ required: true, message: '请选择申请时间', trigger: 'blur' }],
                },
                addRules: {
                    // trigger: 'blur'鼠标失去焦点时触发事件
                    name: [{ required: true, message: '请选择案卷', trigger: 'blur' }],
                    jzType: [{ required: true, message: '请选择卷宗类型', trigger: 'blur' }],
                    registrant: [{ required: true, message: '请选择登记人', trigger: 'blur' }],
                    registDate: [{ required: true, message: '请选择登记时间', trigger: 'blur' }]
                },
                timeRange: [],
                timeShow: false,
                // tableData: {},
                tableData: [],
                pageNum: 1,
                pageSize: 10,
                pages: 0,
                total: 0,
                url: {
                    ajHistory: '/aj/jz-history/insert',
                    registrantsPage: '/auth/user/info/list',
                    ajPage: '/aj/record/allType',
                    page: '/aj/jz-manage',
                    insert:'/aj/jz-manage/insert',
                    update:'/aj/jz-manage//update/{0}',
                    delete:'/aj/jz-manage//delete/{0}',

                    // pageLog: '/sys/log',
                    // export: '/sys/log/export'
                }
            }
        },
        created() {
            this.queryTimeChanged(this.timeSelect)
            this.getDataList()
            this.getList()
            this.getRegistrants()
        },
        computed: {
            typeText() {
                if (this.type_dia === 1){
                    return '修改'
                }else if (this.type_dia === 0){
                    return '入库'
                }else if (this.type_dia === 2){
                    return '详情'
                }else if (this.type_dia === 3){
                    return '临时出库'
                }else if (this.type_dia === 4){
                    return '归还入库'
                }else if (this.type_dia === 5){
                    return '移交出库'
                }else if (this.type_dia === 6){
                    return '轨迹'
                }
            }
        },

        methods: {
            //轨迹
            handleTracks(row){
                this.tracksForm = JSON.parse(JSON.stringify(row))
                this.type_dia = 6
                this.tracksDialogVisible = true
            },
            handleEverOut(row){
                this.everOutForm = JSON.parse(JSON.stringify(row))
                this.everOutForm.status = '移交出库'
                this.type_dia = 5
                //移交出库以后,再点击确认时候poisition赋值null
                // this.everOutForm.position = ''
                //将所在行信息获取赋值,然后根据此行name查找原先数据表中对应id
                this.jzManageHistory = row
                // this.jzManageHistory.jzId = row.id
                // console.log(this.jzManageHistory.jzId)
                this.visableOther(row.name)
                this.jzManageHistory.jzId = this.jzId
                this.everOutDialogVisible = true
                if (!isEmpty(this.$refs.everOutForm)) {
                    this.$refs.everOutForm.resetFields()
                }
            },
            handleTempBack(row){
                this.tempBackForm = JSON.parse(JSON.stringify(row))
                this.tempBackForm.status = '已入库'
                this.type_dia = 4
                this.backDialogVisible = true
                //将所在行信息获取赋值,然后根据此行name查找原先数据表中对应id
                this.jzManageHistory = row
                // this.jzManageHistory.jzId = row.id
                // console.log(this.jzManageHistory.jzId)
                this.visableOther(row.name)
                this.jzManageHistory.jzId = this.jzId
                if (!isEmpty(this.$refs.tempBackForm)) {
                    this.$refs.tempBackForm.resetFields()
                }
            },
            handleTempOut(row){
                this.tempOutForm = JSON.parse(JSON.stringify(row))
                this.tempOutForm.status = '临时出库'
                // this.tempOutForm.tempApplyMan = ''
                this.type_dia = 3
                this.outDialogVisible = true
                //将所在行信息获取赋值,然后根据此行name查找原先数据表中对应id
                this.jzManageHistory = row
                // this.jzManageHistory.jzId = row.id
                // console.log(this.jzManageHistory.jzId)
                this.visableOther(row.name)
                this.jzManageHistory.jzId = this.jzId
                    // console.log(this.jzManageHistory.jzId)
                if (!isEmpty(this.$refs.tempOutForm)) {
                    this.$refs.tempOutForm.resetFields()
                }
            },
            getRegistrants(){
                this.$http.get(this.url.registrantsPage).then(data => {
                    this.registrants = data.result
                    this.tempApplyMans = data.result
                    this.tempBackMans = data.result
                    this.everApplyMans = data.result
                })
            },
            visableOther(name){
                for (let item in this.ajList){
                    if (this.ajList[item].name == name){
                        // console.log(this.ajList[item].type)
                        this.jzId = this.ajList[item].id
                        // console.log(this.jzId)
                        this.addForm.ajType = this.ajList[item].type
                        this.addForm.code =this.ajList[item].code
                        this.addForm.applyUnit =this.ajList[item].department
                    }
                }
            },

            //获取所有案卷的信息封装到列表
            getList(){
                this.$http.get(this.url.ajPage).then(data => {
                    this.ajList = data.result;
                    // console.log(this.ajList)
                })
            },

            handleDetail(row) {
                this.addForm = JSON.parse(JSON.stringify(row))
                this.type_dia = 2
                this.dialogVisible = true
                if (!isEmpty(this.$refs.addForm)) {
                    this.$refs.addForm.resetFields()
                }
            },
            handleUpdate(row) {
                this.addForm = JSON.parse(JSON.stringify(row))
                this.type_dia = 1
                this.dialogVisible = true
                //将所在行信息获取赋值,然后根据此行name查找原先数据表中对应id
                this.jzManageHistory = row
                // this.jzManageHistory.jzId = row.id
                // console.log(this.jzManageHistory.jzId)
                this.visableOther(row.name)
                this.jzManageHistory.jzId = this.jzId
                if (!isEmpty(this.$refs.addForm)) {
                    this.$refs.addForm.resetFields()
                }
            },
            handleDelete(row) {
                this.$confirm('确认删除?', '提示', { type: 'warning' })
                    .then(() => {
                        if (!isEmpty(row) && !isEmpty(row.id)) {
                            var url = stringFormat(this.url.delete, [row.id])
                            this.$http.delete(url).then(() => {
                                this.getDataList()
                            })
                            //    历史记录
                            //将所在行信息获取赋值,然后根据此行name查找原先数据表中对应id
                            this.jzManageHistory = row
                            // this.jzManageHistory.jzId = row.id
                            // console.log(this.jzManageHistory.jzId)
                            this.visableOther(row.name)
                            this.jzManageHistory.jzId = this.jzId
                            this.jzManageHistory.action = "删除"
                            let _form1 = JSON.parse(JSON.stringify(this.jzManageHistory))
                            var address = this.url.ajHistory
                            this.$http.put(address, _form1).then(() => {
                                this.getDataList()
                            })
                        }
                    })
                    .catch(() => {})
            },
            queryTimeChanged(text) {
                let now = new Date()
                switch (text) {
                    case '今日':
                        this.timeShow = false
                        var startTime = getStartTimeOfDate(now)
                        var endTime = getEndTimeOfDate(now)
                        console.log('startTime=', startTime)
                        this.queryParam.startLogTime = formatDate(startTime, 'yyyy-MM-dd hh:mm:ss')
                        this.queryParam.endLogTime = formatDate(endTime, 'yyyy-MM-dd hh:mm:ss')
                        break
                    case '本周':
                        this.timeShow = false
                        var startTime = getStartTimeOfWeek(now)
                        var endTime = getEndTimeOfWeek(now)
                        this.queryParam.startLogTime = formatDate(startTime, 'yyyy-MM-dd hh:mm:ss')
                        this.queryParam.endLogTime = formatDate(endTime, 'yyyy-MM-dd hh:mm:ss')
                        break
                    case '本月':
                        this.timeShow = false
                        var startTime = getStartTimeOfMonth(now)
                        var endTime = getEndTimeOfMonth(now)
                        this.queryParam.startLogTime = formatDate(startTime, 'yyyy-MM-dd hh:mm:ss')
                        this.queryParam.endLogTime = formatDate(endTime, 'yyyy-MM-dd hh:mm:ss')
                        break
                    case '自定义':
                        this.timeShow = true
                        this.queryParam.startLogTime = ''
                        this.queryParam.endLogTime = ''
                        break
                    default:
                        this.timeShow = false
                        this.queryParam.startLogTime = ''
                        this.queryParam.endLogTime = ''
                        break
                }
            },
            handleTimeRangeChanged(text) {
                this.queryParam.startLogTime = text[0]
                this.queryParam.endLogTime = text[1]
            },
            // searchReset() {
            //     this.queryParam = { time: '全部', timeRange: {} }
            // },
            //
            updateConfirm(){
                this.$refs.addForm.validate(valid => {
                    if (valid) {
                        let _form = JSON.parse(JSON.stringify(this.addForm))
                        // console.log("11111")
                        // console.log(_form)
                        //this.type_dia == 0 入库 insert
                        if (this.type_dia === 0){
                            var address = this.url.insert
                            this.$http.put(address, _form).then(() => {
                                this.getDataList()
                            })
                        //    历史记录
                            this.jzManageHistory = this.addForm
                            this.jzManageHistory.jzId = this.jzId
                            this.jzManageHistory.action = "入库"
                            let _form1 = JSON.parse(JSON.stringify(this.jzManageHistory))
                            var address = this.url.ajHistory
                            this.$http.put(address, _form1).then(() => {
                                this.getDataList()
                            })
                        }
                        //this.type_dia == 1 修改
                        else if (this.type_dia === 1){
                            var address = stringFormat(this.url.update, [_form.id])
                            this.$http.put(address, _form).then(() => {
                                this.getDataList()
                            })
                            //    历史记录
                            this.jzManageHistory.action = "编辑"
                            let _form1 = JSON.parse(JSON.stringify(this.jzManageHistory))
                            var address = this.url.ajHistory
                            this.$http.put(address, _form1).then(() => {
                                this.getDataList()
                            })
                        }
                        //this.type_dia == 3 临时出库
                        //    这里未执行
                        else if (this.type_dia === 3){
                            // console.log("临时出库")
                            var address = stringFormat(this.url.update, [_form.id])
                            this.$http.put(address, _form).then(() => {
                                this.getDataList()
                            })

                        }
                        this.dialogVisible = false
                    } else {
                        return false
                    }
                })
            },
            handleTempOutConfirm(){
                this.$refs.tempOutForm.validate(valid => {
                    if (valid) {
                        let _form = JSON.parse(JSON.stringify(this.tempOutForm))
                        if (this.type_dia === 3){
                            console.log("临时出库")
                            var address = stringFormat(this.url.update, [_form.id])
                            this.$http.put(address, _form).then(() => {
                                this.getDataList()
                            })
                            //    历史记录
                            this.jzManageHistory.action = "临时出库"
                            // console.log("111")
                            // console.log(this.jzManageHistory.action)
                            let _form1 = JSON.parse(JSON.stringify(this.jzManageHistory))
                            var address = this.url.ajHistory
                            this.$http.put(address, _form1).then(() => {
                                // console.log("3333")
                                this.getDataList()
                            })
                        }
                        this.outDialogVisible = false
                    } else {
                        return false
                    }
                })
            },
            handleTempBackConfirm(){
                this.$refs.tempBackForm.validate(valid => {
                    if (valid) {
                        let _form = JSON.parse(JSON.stringify(this.tempBackForm))
                        if (this.type_dia === 4){
                            console.log("归还入库")
                            var address = stringFormat(this.url.update, [_form.id])
                            this.$http.put(address, _form).then(() => {
                                this.getDataList()
                            })
                            //    历史记录
                            this.jzManageHistory.action = "归还入库"
                            let _form1 = JSON.parse(JSON.stringify(this.jzManageHistory))
                            var address = this.url.ajHistory
                            this.$http.put(address, _form1).then(() => {
                                this.getDataList()
                            })
                        }
                        this.backDialogVisible = false
                    } else {
                        return false
                    }
                })
            },
            handleEverOutConfirm(){
                this.$refs.everOutForm.validate(valid => {
                    if (valid) {
                        this.everOutForm.position = ''
                        let _form = JSON.parse(JSON.stringify(this.everOutForm))
                        if (this.type_dia === 5){
                            console.log("移交出库")
                            var address = stringFormat(this.url.update, [_form.id])
                            this.$http.put(address, _form).then(() => {
                                this.getDataList()
                            })
                            //    历史记录
                            this.jzManageHistory.action = "移交出库"
                            let _form1 = JSON.parse(JSON.stringify(this.jzManageHistory))
                            var address = this.url.ajHistory
                            this.$http.put(address, _form1).then(() => {
                                this.getDataList()
                            })
                        }
                        this.everOutDialogVisible = false
                    } else {
                        return false
                    }
                })
            },
            handleAdd() {
                this.type_dia = 0
                this.addForm = {
                    // value:'',
                    name: '',
                    code: '',
                    ajType:'',
                    jzType:'',
                    registDate:'',
                    registrant:'',
                    status:'已入库',
                    position:'',
                    applyUnit:'',
                    description:''
                }
                this.dialogVisible = true
                if (!isEmpty(this.$refs.addForm)) {
                    this.$refs.addForm.resetFields()
                }
            },
            getDataList() {
                let params = { _pageSize: this.pageSize, _pageNum: this.pageNum, ...this.queryParam }

                // console.log("111")
                // console.log(params)
                this.$http.get(this.url.page, {params}).then(data => {
                    // console.log(data)
                    let result = data.result
                    this.tableData = result.records
                    // console.log(this.tableData)
                    this.pageNum = result.current
                    this.pageSize = result.size
                    this.pages = result.pages
                    this.total = result.total
                })
            },
            handlePageChange(page) {
                this.pageNum = page
                this.getDataList()
            },
            handleSizeChange(size) {
                this.pageSize = size
                this.getDataList()
            }
        }
    }
</script>
